package logic

import (
	"context"
	"shop/shoprpc/shoprpc"

	"shop/api/internal/svc"
	"shop/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewShopInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopInfoLogic {
	return &ShopInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ShopInfoLogic) ShopInfo(req *types.ShopInfoRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	info, err := l.svcCtx.ShopRpc.ShopInfo(l.ctx, &shoprpc.ShopInfoRequest{
		Id:     int64(req.Id),
		Userid: int64(req.Userid),
	})
	if err != nil {
		return &types.Response{
			Code:    0,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "详情查询成功",
		Data:    info,
	}, nil
}
